﻿#include <iostream>
#include<Windows.h>

using namespace std;

int main(int argc,char* argv[])
{	
	//通过进程启动Winsock DLL使用
	WSADATA ws;
	WSAStartup(MAKEWORD(2, 2), &ws);

	for (int i = 0; i < 1000; i++) {
		//创建socket，创建失败返回-1，AF_INET表示ipv4协议，SOCK_STREAM表示接受tcp/ip协议的数据
		int sock = socket(AF_INET, SOCK_STREAM, 0);
		if (sock == -1) {
			cout << "create socket failed" << endl;
			return -1;
		}
		cout << "[" << sock << "]" << endl;

		//socket关闭
		closesocket(sock);
	}

	return 0;
}

